<?php
class Charset{
	
	public static function convert($incharset,$outcharset,$content)
	{
		/* 使用iconv */
		if (function_exists("iconv"))
		{
			$content = iconv($incharset,$outcharset,$content);
		}
		/* 使用mb_convert_encoding */
		else if (function_exists("mb_convert_encoding"))
		{
			$content = mb_convert_encoding($content,$outcharset,$incharset);
		}
		
		return $content;
	}
	public static function utf8_gbk($content)
	{
		return self::convert('UTF-8','GBK',$content);
	}
	
	public static function gbk_utf8($content)
	{
		return self::convert('GBK','UTF-8',$content);
	}
}